import Mapper.userMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import pojo.user;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class MybatisTest {
    public static void main(String[] args) throws IOException {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);


        List<user> u;
       userMapper um=sqlSessionFactory.openSession().getMapper(userMapper.class);

        u=um.selectAll();
        System.out.println(u.size());
        user u2=um.selectByUsername("hjq");
        System.out.println(u2.getId()+" "+u2.getUsername()+" "+u2.getPassword());
    }
}
